<template>
    <div class="login-content">
        <Login @ALogin="handlerLogin"></Login>
    </div>
</template>

<script>
    import Login from '../components/LoginComp.vue'

    export default {
        name: "login",
        components: {
            Login
        },
        data() {
            return {

            }
        }, methods: {
            handlerLogin(user, isLoading) {
                setTimeout(() => {
                    axios.post('/api/login', user)
                        .then((res) => {
                            isLoading = false
                            if (res.data.code === 1) {
                                localStorage.setItem('token', res.data.data.token)
                                this.$router.replace('/plugin')
                            } else {
                                this.getVerifyCode()
                                this.$Toast.errorToast(res.data.msg)
                            }
                        })
                        .catch((error) => {
                            isLoading = false
                        })
                }, 300)
            }
        }
    }
</script>

<style scoped>
    .login-content {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 100%;
    }

</style>